package cn.hsa.xxx.bookData.controller;


import cn.hsa.hsaf.core.framework.web.WrapperResponse;
import cn.hsa.xxx.api.dto.InventoryBatchDTO;
import cn.hsa.xxx.api.service.InventoryBatchService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RequestMapping("/web/bookData/inventoryBatch")
@RestController
@Slf4j
public class InventoryBatchController {

    @Autowired
    private InventoryBatchService inventoryBatchService;

    @PostMapping("/addInventoryBatch")
    public WrapperResponse<InventoryBatchDTO> addInventoryBatch(@RequestBody InventoryBatchDTO inventoryBatchDTO) {
        InventoryBatchDTO result = inventoryBatchService.add(inventoryBatchDTO);
        return WrapperResponse.success(result);
    }

    @PostMapping("/deleteInventoryBatch")
    public WrapperResponse<String> deleteInventoryBatch(@RequestParam String id) {
        String result = inventoryBatchService.delete(id);
        return WrapperResponse.success(result);
    }

    @GetMapping("/getInventoryBatchById")
    public WrapperResponse<InventoryBatchDTO> getInventoryBatch(@RequestParam String id) {
        InventoryBatchDTO result = inventoryBatchService.get(id);
        return WrapperResponse.success(result);
    }

    @PostMapping("/updateInventoryBatch")
    public WrapperResponse<String> updateInventoryBatch(@RequestBody InventoryBatchDTO inventoryBatchDTO) {
        String str = inventoryBatchService.update(inventoryBatchDTO);
        return WrapperResponse.success(str);
    }

    @GetMapping("/page")
    public WrapperResponse<List<InventoryBatchDTO>> getPageInventoryBatch(int pageNo, int pageSize) {
        List<InventoryBatchDTO> inventoryBatchDTOList = inventoryBatchService.getPage(pageNo, pageSize);
        return WrapperResponse.success(inventoryBatchDTOList);
    }

}
